//
// Created by Jisam on 2024/8/10 15:33.
// solve
#include <bits/stdc++.h>

#define endl "\n"
#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

using namespace std;
struct node{
    int a,b,c;
};
int dx[] = {-1,1,0,0, };
int dy[] = {0,0,-1,1, };
void solve() {
    int n , m ;
    cin >> n >> m;
    vector<vector<i64>> a(n,vector<i64>(m,0));
    vector<vector<int>> vis(n,vector<int>(m,0));
    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < m; j ++){
            cin >> a[i][j];
        }
    }
    queue<node> q;
    q.push({0,0,0});
    vis[0][0] = 1;
    while(!q.empty()){
        auto [x,y,z] = q.front();
        q.pop();
        if(x == n  - 1&& y == m - 1 ){
            if(z <= a[x][y]){
                cout << "Yes\n";
                return ;
            }
        }
        for(int i = 0 ; i < 4 ; i ++){
            int tx = x + dx[i];
            int ty = y + dy[i];
            if(tx >= 0 && ty >= 0 && tx <n && ty < m && vis[tx][ty] == 0 && a[tx][ty] >= z){
                cerr << x << " " << y << " " << z <<"\n";
                q.push({tx,ty,z + 1});
                vis[tx][ty] = 1;
            }
        }
    }
    cout << "No\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--) solve();
//    cout << "\n"[];
    return 0;
}